package de.tabuma.ssoclient.logik;

import java.util.*;
import de.tabuma.ssoclient.entity.*;
import de.tabuma.lib.webservice.client.*;

/**
 *
 * @author alefen
 */
public class GroupPrivilegFacade {

    private static String soapUrl = "https://tabumasso.appspot.com/webservice";
    public static int create(GroupPrivileg groupPrivileg, String ssoId) throws Exception {
        String methodName = "GroupPrivilegService_create";
        String soapAction = "GroupPrivilegService_create";

        Class returnType = Integer.class;
        Object params[] = {groupPrivileg, ssoId};

        Integer obj = (Integer) ExecuteMethod.executeMethod(methodName, soapAction, soapUrl, params, returnType, null);
        groupPrivileg.setId(obj.longValue());
        GroupPrivilegHashFacade.put(groupPrivileg, ssoId);
        return obj.intValue();
    }

    public static void update(GroupPrivileg groupPrivileg, String ssoId) throws Exception {
        String methodName = "GroupPrivilegService_update";
        String soapAction = "GroupPrivilegService_update";

        Object params[] = {groupPrivileg, ssoId};
        ExecuteMethod.executeMethod(methodName, soapAction, soapUrl, params, null, null);
        GroupPrivilegHashFacade.put(groupPrivileg, ssoId);
    }

    public static GroupPrivileg get(int id, String ssoId) throws Exception {
        String methodName = "GroupPrivilegService_get";
        String soapAction = "GroupPrivilegService_get";

        Class returnType = GroupPrivileg.class;
        Object params[] = {Integer.valueOf(id), ssoId};

        GroupPrivileg obj = GroupPrivilegHashFacade.get(id, ssoId);
        if(obj==null) {
            obj = (GroupPrivileg) ExecuteMethod.executeMethod(methodName, soapAction, soapUrl, params, returnType, null);
        }
        return obj;
    }

    //TODO get to know why GroupPrivilegWebservice had only three methods
    public static List<GroupPrivileg> getList1(int id, String ssoId) throws Exception {
        String methodName = "GroupPrivilegService_getList";
        String soapAction = "GroupPrivilegService_getList";

        Class returnType = List.class;
        Class returnType1 = GroupPrivileg.class;
        Object params[] = {Integer.valueOf(id), ssoId};

        List<GroupPrivileg> obj = GroupPrivilegHashFacade.getList1(id, ssoId);
        if(obj==null) {
            obj = (List<GroupPrivileg>) ExecuteMethod.executeMethod(methodName, soapAction, soapUrl, params, returnType, returnType1);
            GroupPrivilegHashFacade.setList1(id, obj, ssoId);
        }
        return obj;
    }

    public static List<GroupPrivileg> getList2(int id, String ssoId) throws Exception {
        String methodName = "GroupPrivilegService_getList1";
        String soapAction = "GroupPrivilegService_getList1";

        Class returnType = List.class;
        Class returnType1 = GroupPrivileg.class;
        Object params[] = {Integer.valueOf(id), ssoId};

        List<GroupPrivileg> obj = GroupPrivilegHashFacade.getList2(id, ssoId);
        if(obj==null) {
            obj = (List<GroupPrivileg>) ExecuteMethod.executeMethod(methodName, soapAction, soapUrl, params, returnType, returnType1);
            GroupPrivilegHashFacade.setList2(id, obj, ssoId);
        }
        return obj;
    }

    public static void remove(int id, String ssoId) throws Exception {
        String methodName = "GroupPrivilegService_remove";
        String soapAction = "GroupPrivilegService_remove";

        Object params[] = {Integer.valueOf(id), ssoId};

        ExecuteMethod.executeMethod(methodName, soapAction, soapUrl, params, null, null);
        GroupPrivilegHashFacade.remove(id, ssoId);
    }
}
